#!/usr/bin/env bash
set -e
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
# Function :CentOS7.X 一键安装在线同步repo镜像
# Platform :RedHatEL7.x Based Platform
# Version  :1.01
# Date     :2022-10-19
# Author   :mugoLH
# Contact  :hxsaj@126.com
# Company  :
# depend on:
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
info_p(){  printf "\e[1;32;40m%-18s %-1s\n\e[0m" "${1}" "${2}"  >&1 ;}
tips_p(){  printf "\e[1;36;40m%-18s %-1s\n\e[0m" "${1}" "${2}"  >&1 ;}
error_p(){ printf "\e[1;35;40m%-18s %-1s\n\e[0m" "${1}" "${2}"  >&1 ;}

# 安装依赖
yum -y install gcc gcc-c++ make automake autoconf pcre pcre-devel zlib zlib-devel openssl openssl-devel libtool wget rsync createrepo yum-utils

# 关闭firewall服务
systemctl stop firewalld && systemctl disable firewalld

# 关闭selinux
setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config

# 下载nginx
wget http://nginx.org/download/nginx-1.16.1.tar.gz

# 解压并编译
tar -zxf nginx-1.16.1.tar.gz && cd nginx-1.16.1

./configure \
--prefix=/opt/nginx \
--sbin-path=/opt/nginx/sbin/nginx \
--conf-path=/opt/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre

make && make install

# 新增nginx运行用户nginx
groupadd nginx && useradd -g nginx nginx -s /bin/false

# 同步



